Change boolean config option parsing to allow True and Y and similar useful
authoremellor@ewan <emellor@ewan>
Wed, 5 Oct 2005 16:48:36 +0000 (17:48 +0100)
committeremellor@ewan <emellor@ewan>
Wed, 5 Oct 2005 16:48:36 +0000 (17:48 +0100)
things.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendRoot.py

index 5162163cbac870373232ad058fb8b65d9ab28fee..f170b1192b43a72202a5da363653e8d0d55c780c 100644 (file)
@@ -26,6 +26,7 @@ configured values.
 
 import os
 import os.path
+import string
 import sys
 
 from XendLogging import XendLogging
@@ -238,10 +239,10 @@ class XendRoot:
         return sxp.child_value(self.config, name, val=val)
 
     def get_config_bool(self, name, val=None):
-        v = self.get_config_value(name, val)
-        if v in ['yes', '1', 'on', 'true', 1, True]:
+        v = string.lower(str(self.get_config_value(name, val)))
+        if v in ['yes', 'y', '1', 'on',  'true',  't']:
             return True
-        if v in ['no', '0', 'off', 'false', 0, False]:
+        if v in ['no',  'n', '0', 'off', 'false', 'f']:
             return False
         raise XendError("invalid xend config %s: expected bool: %s" % (name, v))